//
//  AddBillViewController.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/11/2.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class AddBillViewController: BillRootViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.title = addBill
        addSubView()
    }
    
    //MARK: 创建tableView
    fileprivate func addSubView() {
        
        let scrollView = UIScrollView()
        scrollView.backgroundColor = UIColor.mineColor()
        scrollView.showsVerticalScrollIndicator = false
        scrollView.bounces = false
        self.view.addSubview(scrollView)
        
        let typeView = AddTypeBillView()
        typeView.delegate = self
        scrollView.addSubview(typeView)
        
        let bankView = AddBankBillView()
        bankView.delegate = self
        scrollView.addSubview(bankView)
        
        scrollView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview().inset(UIEdgeInsets.zero)
        }
        
        typeView.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.left.right.equalTo(self.view)
            make.height.equalTo(RATIO_H(maxNum: 220))
        }
        
        bankView.snp.makeConstraints { (make) in
            make.top.equalTo(typeView.snp.bottom).offset(RATIO_H(maxNum: 10))
            make.left.right.equalTo(self.view)
            make.height.equalTo(RATIO_H(maxNum: 800))
        }
        
        self.view.layoutIfNeeded()
        
        scrollView.contentSize = .init(width: ScreenW, height: bankView.frame.maxY)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()

        
    }
    



}

extension AddBillViewController :  AddBankBillViewDelegate,AddTypeBillViewDelegate {
    
    //MARK: 选择账单类型
    func selectBillType(index: Int) {
        
        switch index {
        case 0:
            let mailBillVC = MailBillViewController()
            self.navigationController?.pushViewController(mailBillVC, animated: true)
        case 1:
            let otherBillVC = OtherBillViewController()
            self.navigationController?.pushViewController(otherBillVC, animated: true)
        case 2:
            let inputBillVC = InputBillViewController()
            self.navigationController?.pushViewController(inputBillVC, animated: true)
        default:
            break
        }
    }
    
    //MARK: 选择银行账单
    func selectBankBill(title: String) {
        
        let bankBillVC = BankBillRootViewController.init(title: title)
        self.navigationController?.pushViewController(bankBillVC, animated: true)
    }
}
